home *** CD-ROM | disk | FTP | other *** search
/ Sports Illustrated for Kids - Awesome Athletes! / Sports Illustrated for Kids - Awesome Athletes!.iso / tr.dir / 00029_General Routines 2.ls < prev    next >
Encoding:
Text File  |  1996-04-18  |  9.3 KB  |  311 lines

  1. on SetPlayerScores
  2.   global gzTRPlayerObj, gcTRPLYR1SCORECH, gcTRPLYR2SCORECH
  3.   set the text of field "Player1Score" to EMPTY
  4.   set the text of field "Player2Score" to EMPTY
  5.   if mGetPlayMode(gTRGameObj) = 1 then
  6.     set vScore to mGetMyCurrentScore(getAt(gzTRPlayerObj, 1))
  7.     set the text of field "Player1Score" to string(vScore)
  8.     set the visible of sprite gcTRPLYR1SCORECH to 1
  9.     set the visible of sprite gcTRPLYR2SCORECH to 0
  10.     set the locH of sprite gcTRPLYR1SCORECH to 333
  11.     set the locV of sprite gcTRPLYR1SCORECH to 432
  12.     puppetSprite(gcTRPLYR1SCORECH, 1)
  13.   else
  14.     set vScore1 to mGetMyCurrentScore(getAt(gzTRPlayerObj, 1))
  15.     set vScore2 to mGetMyCurrentScore(getAt(gzTRPlayerObj, 2))
  16.     set the text of field "Player1Score" to string(vScore1)
  17.     set the text of field "Player2Score" to string(vScore2)
  18.     set the locH of sprite gcTRPLYR1SCORECH to 230
  19.     set the locV of sprite gcTRPLYR1SCORECH to 431
  20.     set the visible of sprite gcTRPLYR1SCORECH to 1
  21.     set the visible of sprite gcTRPLYR2SCORECH to 1
  22.   end if
  23.   SetScoreAttribs()
  24.   updateStage()
  25. end
  26.  
  27. on PlaceTurnDart
  28.   global gcTRTURNDARTCH, gTRGameObj
  29.   if mGetPlayMode(gTRGameObj) = 1 then
  30.     set the visible of sprite gcTRTURNDARTCH to 0
  31.     return 
  32.   end if
  33.   if mGetWhosTurn(gTRGameObj) = 1 then
  34.     set the castNum of sprite gcTRTURNDARTCH to the number of cast "DartPlayer1"
  35.     set the locV of sprite gcTRTURNDARTCH to 425
  36.     set the locH of sprite gcTRTURNDARTCH to 167
  37.   else
  38.     set the castNum of sprite gcTRTURNDARTCH to the number of cast "DartPlayer2"
  39.     set the locV of sprite gcTRTURNDARTCH to 425
  40.     set the locH of sprite gcTRTURNDARTCH to 460
  41.   end if
  42.   set the visible of sprite gcTRTURNDARTCH to 1
  43.   puppetSprite(gcTRTURNDARTCH, 1)
  44.   updateStage()
  45. end
  46.  
  47. on SwapTurns
  48.   global gTRGameObj
  49.   if mGetWhosTurn(gTRGameObj) = 1 then
  50.     mSetWhosTurn(gTRGameObj, 2)
  51.   else
  52.     mSetWhosTurn(gTRGameObj, 1)
  53.   end if
  54. end
  55.  
  56. on DoDoubleValues
  57.   global gzTRBalloonObj, gcTRBAL_CH1, gcTR_DOUBLE3_CH
  58.   set vBalloonNums to list()
  59.   set vKeepItUp to 1
  60.   set vNumLables to random(3)
  61.   repeat while vKeepItUp
  62.     set vNum to random(30)
  63.     if not getPos(vBalloonNums, vNum) then
  64.       append(vBalloonNums, vNum)
  65.     end if
  66.     if count(vBalloonNums) > 2 then
  67.       set vKeepItUp to 0
  68.     end if
  69.   end repeat
  70.   mSetAmIDouble(getAt(gzTRBalloonObj, getAt(vBalloonNums, 1)), 1)
  71.   mSetHaveIBeenDouble(getAt(gzTRBalloonObj, getAt(vBalloonNums, 1)), 1)
  72.   if vNumLables > 1 then
  73.     mSetAmIDouble(getAt(gzTRBalloonObj, getAt(vBalloonNums, 2)), 1)
  74.     mSetHaveIBeenDouble(getAt(gzTRBalloonObj, getAt(vBalloonNums, 2)), 1)
  75.   end if
  76.   if vNumLables > 2 then
  77.     mSetAmIDouble(getAt(gzTRBalloonObj, getAt(vBalloonNums, 3)), 1)
  78.     mSetHaveIBeenDouble(getAt(gzTRBalloonObj, getAt(vBalloonNums, 3)), 1)
  79.   end if
  80. end
  81.  
  82. on EraseScoreBoard
  83.   global gcTRROVER
  84.   set the castNum of sprite gcTRROVER to the number of cast "BlankScoreBoard"
  85.   set the locH of sprite gcTRROVER to 320
  86.   set the locV of sprite gcTRROVER to 436
  87.   updateStage()
  88. end
  89.  
  90. on myDelay aTicks
  91.   startTimer()
  92.   repeat while the timer < aTicks
  93.     nothing()
  94.   end repeat
  95. end
  96.  
  97. on TurnOnScoreBoards
  98.   global gcTRSCOREBRD_CH, gcTRPLYR1SCORECH, gcTRPLYR2SCORECH
  99.   puppetSprite(gcTRPLYR1SCORECH, 1)
  100.   puppetSprite(gcTRPLYR2SCORECH, 1)
  101.   puppetSprite(gcTRSCOREBRD_CH, 1)
  102.   if mGetPlayMode(gTRGameObj) = 1 then
  103.     set the castNum of sprite gcTRSCOREBRD_CH to the number of cast "SinglePlayerScoreBoard"
  104.     set the locH of sprite gcTRSCOREBRD_CH to 320
  105.     set the locV of sprite gcTRSCOREBRD_CH to 446
  106.     set the visible of sprite gcTRSCOREBRD_CH to 1
  107.     set the visible of sprite gcTRPLYR1SCORECH to 1
  108.   else
  109.     set the castNum of sprite gcTRSCOREBRD_CH to the number of cast "DoublePlayerScoreBoard"
  110.     set the locH of sprite gcTRSCOREBRD_CH to 316
  111.     set the locV of sprite gcTRSCOREBRD_CH to 446
  112.     set the visible of sprite gcTRSCOREBRD_CH to 1
  113.     set the visible of sprite gcTRPLYR1SCORECH to 1
  114.     set the visible of sprite gcTRPLYR2SCORECH to 1
  115.   end if
  116.   updateStage()
  117. end
  118.  
  119. on ShowQuestionWindow
  120.   global gTRGameObj, gcTRROVER, gTRButtInhibit
  121.   set gTRButtInhibit to 1
  122.   set vAnswerRect to list()
  123.   addAt(vAnswerRect, 1, rect(153, 210, 500, 245))
  124.   addAt(vAnswerRect, 2, rect(153, 255, 500, 287))
  125.   addAt(vAnswerRect, 3, rect(153, 295, 500, 330))
  126.   addAt(vAnswerRect, 4, rect(395, 333, 500, 353))
  127.   set vOnTheButton to 0
  128.   set vDontKnow to 0
  129.   set vPlayMode to mGetPlayMode(gTRGameObj)
  130.   if vPlayMode = 1 then
  131.     ShowOneTwoLabel("one", 349, 115)
  132.   else
  133.     if mGetWhosTurn(gTRGameObj) = 1 then
  134.       ShowOneTwoLabel("one", 349, 115)
  135.     else
  136.       ShowOneTwoLabel("two", 349, 115)
  137.     end if
  138.   end if
  139.   set vBeenUp to 0
  140.   set vKeepItUp to 1
  141.   repeat while vKeepItUp
  142.     set vMouse to point(the mouseH, the mouseV)
  143.     if vBeenUp = 0 then
  144.       set vBeenUp to the mouseUp
  145.     end if
  146.     set vRect to 0
  147.     repeat with vI = 1 to 4
  148.       if inside(vMouse, getAt(vAnswerRect, vI)) then
  149.         set vRect to vI
  150.         if vRect = 4 then
  151.           set the castNum of sprite 47 to cast "DontKnowButton.RollOver"
  152.           set the castNum of sprite gcTRROVER to the number of cast "D:"
  153.           updateStage()
  154.         else
  155.           set the castNum of sprite 47 to cast "DontKnowButton"
  156.           updateStage()
  157.           RollOverAnswers(vRect)
  158.         end if
  159.         exit repeat
  160.       end if
  161.     end repeat
  162.     if vRect = 0 then
  163.       RollOverAnswers(0)
  164.     end if
  165.     if the mouseDown and (vOnTheButton = 0) and vBeenUp then
  166.       if vRect = 4 then
  167.         set gTRButtInhibit to 0
  168.         repeat while the mouseDown and inside(vMouse, getAt(vAnswerRect, 4))
  169.           set the castNum of sprite 47 to the number of cast "DontKnowButton.dep"
  170.           updateStage()
  171.           set vMouse to point(the mouseH, the mouseV)
  172.           set vOnTheButton to 1
  173.           if the mouseUp and inside(vMouse, getAt(vAnswerRect, 4)) then
  174.             ComputeScore(0)
  175.             set vKeepItUp to 0
  176.             set vOnTheButton to 0
  177.             set vDontKnow to 1
  178.             updateStage()
  179.             repeat while soundBusy(1)
  180.               nothing()
  181.             end repeat
  182.           end if
  183.         end repeat
  184.       else
  185.         if vRect = 0 then
  186.           nothing()
  187.           set gTRButtInhibit to 0
  188.         else
  189.           repeat while the mouseDown
  190.             nothing()
  191.           end repeat
  192.           set vMouse to point(the mouseH, the mouseV)
  193.           if inside(vMouse, getAt(vAnswerRect, vRect)) then
  194.             set vMouse to point(the mouseH, the mouseV)
  195.             set vHotSpot to rect(400, 255, 500, 287)
  196.             if not inside(vMouse, vHotSpot) then
  197.               set gTRButtInhibit to 0
  198.             end if
  199.             set vKeepItUp to 0
  200.             set vGotItRight to ComputeScore(vRect)
  201.           else
  202.             nothing()
  203.           end if
  204.         end if
  205.       end if
  206.       set the castNum of sprite 47 to cast "DontKnowButton"
  207.       updateStage()
  208.     end if
  209.     if not inside(vMouse, getAt(vAnswerRect, 4)) then
  210.       set the castNum of sprite 47 to cast "DontKnowButton"
  211.       updateStage()
  212.     end if
  213.     if vOnTheButton then
  214.       if (vRect <> 4) and the mouseUp then
  215.         set vOnTheButton to 0
  216.       end if
  217.     end if
  218.   end repeat
  219.   set the visible of sprite gcTRROVER to 0
  220.   set the locH of sprite gcTRROVER to -10
  221.   set the locV of sprite gcTRROVER to -10
  222.   set the trails of sprite gcTRROVER to 0
  223.   updateStage()
  224.   if vGotItRight then
  225.     if mGetPopCount(gTRGameObj) = 29 then
  226.       go("LastQuestRight")
  227.     else
  228.       go("ShowAnswerRight")
  229.       puppetSprite(44, 1)
  230.       set the castNum of sprite 44 to cast ("RIGHT" & random(27) & ".PIC")
  231.     end if
  232.   else
  233.     if mGetPopCount(gTRGameObj) = 29 then
  234.       go("LastQuestWrong")
  235.     else
  236.       go("ShowAnswerWrong")
  237.     end if
  238.     if vDontKnow then
  239.       puppetSprite(44, 0)
  240.     else
  241.       puppetSprite(44, 1)
  242.       set the castNum of sprite 44 to cast ("WRONG" & random(26) & ".PIC")
  243.     end if
  244.   end if
  245.   if vPlayMode = 1 then
  246.     ShowOneTwoLabel("one", 349, 177)
  247.   else
  248.     if mGetWhosTurn(gTRGameObj) = 1 then
  249.       ShowOneTwoLabel("two", 349, 177)
  250.     else
  251.       ShowOneTwoLabel("one", 350, 177)
  252.     end if
  253.   end if
  254. end
  255.  
  256. on ShowOneTwoLabel aPlayer, aH, aV
  257.   global gcTRROVER
  258.   if aPlayer = "one" then
  259.     set the castNum of sprite gcTRROVER to the number of cast "OneLabel"
  260.   else
  261.     set the castNum of sprite gcTRROVER to the number of cast "TwoLabel"
  262.   end if
  263.   set the locH of sprite gcTRROVER to aH
  264.   set the locV of sprite gcTRROVER to aV
  265.   set the visible of sprite gcTRROVER to 1
  266.   set the trails of sprite gcTRROVER to 1
  267.   updateStage()
  268.   set the castNum of sprite gcTRROVER to the number of cast "gRover"
  269.   set the locH of sprite gcTRROVER to -10
  270.   set the locV of sprite gcTRROVER to -10
  271.   updateStage()
  272. end
  273.  
  274. on NextRound
  275.   global gTRGameObj
  276.   mIncrementPopCount(gTRGameObj)
  277.   PlaceTurnDart()
  278. end
  279.  
  280. on GetRandomQuestion
  281.   global gzTR_BeenSelected
  282.   set vRetVal to 0
  283.   set vRetVal to random(10)
  284.   if count(gzTR_BeenSelected) = 10 then
  285.     set gzTR_BeenSelected to list()
  286.   end if
  287.   repeat while getPos(gzTR_BeenSelected, vRetVal)
  288.     set vRetVal to random(10)
  289.   end repeat
  290.   append(gzTR_BeenSelected, vRetVal)
  291.   return vRetVal
  292. end
  293.  
  294. on TestNameLength
  295.   global gzTRPlayerObj
  296.   return 1
  297.   set vMaxLength to 20
  298.   GetPlayersNames()
  299.   set vP1 to mGetMyName(getAt(gzTRPlayerObj, 1))
  300.   set vP2 to mGetMyName(getAt(gzTRPlayerObj, 2))
  301.   if length(vP1) > vMaxLength then
  302.     alert("Player One's name is Too Long!")
  303.     return 0
  304.   end if
  305.   if length(vP2) > vMaxLength then
  306.     alert("Player Two's name is Too Long!")
  307.     return 0
  308.   end if
  309.   return 1
  310. end
  311.